<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.dao.*,java.util.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>商品列表</title>

<script src="js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
		<style type="text/css">
			a{
				text-decoration: none;
				color: #000;
			}
			#menu{
				position: relative;
				top: 0px;
				width: 876px;
				height: 10px;
				line-height: 34px;
				margin: auto;
			}
			#menu li{
				float: left;
				display: block;
				width: 92px;
				height: 37px;
				line-height: 37px;
				text-align: center;
				margin-right: 2px;
			}
			#menu li a:link{
				display: block;
				background-color: #edebec;
				font-size: 14px;
				color: #333;
				width: 92px;
				height: 37px;
				line-height: 37px;
			}
			#menu li a:hover{
				background-color: red;
				color: white;
			}
			#menu li ul{
				position: absolute;
				top: 37px;
				width: 90px;
				display: none;
				border: 1px solid #ce070e;
				border-top: none;
				background: #fff;
			}
			#menu li ul li{
				float: left;
				width: 90px;
				height: 37px;
				line-height: 37px;
			}
			#menu li ul li a:link{
				width: 90px;
				height: 37px;
				line-height: 37px;
			}
			#menu li ul li:hover{
				color: white;
				text-decoration: none;
			}
		</style>
		
		<script type="text/javascript">
			$(function(){
				$("#menu>li:has(ul)").hover(
					function(){
						$(this).find('ul').slideDown(500);
					},
					function(){
						$(this).find('ul').slideUp(500);
					}
				);
			});
		</script>

<script type="text/javascript">
    function confirmdialog(){
       if(window.confirm("您确定要删除此条信息？")){
       return true;
       }
       else{
     //  alert("取消删除！");
       return false;
       }      
    }
 </script>
</head>
<body>
<div id="wrap">
			<ul id="menu">
				<li><a href="#">商品管理</a></li>
				<li><a href="login.jsp">商品添加</a>
			</ul>		
		</div>
	<br>
    <h1 align="center">商品信息</h1><hr>    
     <br>
     <form action="UserServlet" method="post"  align="center">
    <input type="hidden" name="methodName" value="5"/>
      <h3 align="center">按編號名稱查询:</h3>
		<h4 align="center">編號：<input type="text" name="goodsid"  value="" title="編號必须为数字" align="center"></input>
		名稱：<input type="text" name="goodsname" value="" title=""></input>
      <input type="submit" value="查询" /></h4>
    </form>
 <br>
  <h3 align="center">全部用户信息如下</h3>
   <table width="1050" border="150" cellSpacing=1 style="border: 1pt dashed ; font-size: 15pt;" height="31" align="center">
    <tr>
    <td>商品编号</td>
    <td>商品名称</td>
    <td>商品价格</td>
    <td>生产日期</td>
    <td>保质期</td>
    
    </tr>
    <%
     response.setCharacterEncoding("UTF-8");
     request.setCharacterEncoding("UTF-8");
     //Page pager=(Page)request.getAttribute("pager");
     List<User> subResult=(List<User>)request.getAttribute("subResult");
       if(!subResult.isEmpty()){
       for(int i=0;i<subResult.size();i++){
            User st=subResult.get(i);
            out.print("<tr>");
            out.print("<td>"+st.getGoodsid()+"</td>");
            out.print("<td>"+st.getGoodsname()+"</td>");
            out.print("<td>"+st.getGoodsprice()+"</td>");
            out.print("<td>"+st.getThedate()+"</td>");  
            out.print("<td>"+st.getShelflife()+"</td>");  
     %>
     <td><a href="UserServlet?id=<%=st.getGoodsid() %>&methodName=<%=2 %>" οnclick="return confirmdialog()">删除</a></td>
     
     <td><a href="UserServlet?id=<%=st.getGoodsid() %>&methodName=<%=4 %>">修改</a></td>
    <% 
    out.print("</tr>");
         }
       }
     %>
     </table>
    
     <br>
</body>
</html>